﻿using Hangfire;
using BgWorks.Models;
using BgWorks.Works;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using BgWorks.Common;
 

namespace BgWorks.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AuthController : ControllerBase
    {

        public AuthController()
        {
             
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="lgoinModel"></param>
        /// <returns></returns>
        [HttpPost]

        public ResponseApi<string> Login([FromBody] LgoinModel lgoinModel)
        {
            ResponseApi<string> res = new ResponseApi<string>();
            if (!string.IsNullOrEmpty(lgoinModel.LoginName) && !string.IsNullOrEmpty(lgoinModel.Password))
            {
                if (lgoinModel.LoginName == "admin" && lgoinModel.Password == "123")
                {
                    res.code = 200;
                }
                else
                {
                    res.msg = "用户名或密码错误！";
                }
            }
            else
            {
                res.msg = "用户名或密码不能为空！";
            }
            return res;
        }
    }

    public class LgoinModel
    {
        public string LoginName { get; set; }
        public string Password { get; set; }
    }
}
